import axios from 'axios';

export interface MatchDTO {
  matchScheduleId?: number;
  matchTitle: string;
  matchType: number;
  startTime: string;
  endTime: string;
  raceMethod: number;
  itemList: number[];
  scheduleList: number[];
  groupItemId: number;
  quarterFinalNum: number;
  semiFinalNum: number;
  integralDis: {
    ranking: number;
    integral: number;
  }[];
}

export interface MatchRes extends MatchDTO {
  pointRaceId: number;
  isRecord: boolean;
  createTime: string;
  updateTime: string;
  isApproved: number;
  userId: number;
}

export interface Params {
  curPage?: number;
  pageSize?: number;
  dateField?: string;
  startDate?: string;
  endDate?: string;
  orderField?: string;
  orderType?: string;
  rangeField?: string;
  rangeLValue?: string;
  rangeRValue?: string;
  search?: string;
  searchField?: string;
  statusField?: string;
  statusValue?: string;
}

export function getMatchList(data?: Params) {
  return axios.get<{ records: MatchRes[] }>(`${import.meta.env.VITE_API_Admin_URL}match/list`, {
    params: data,
  });
}

export function addMatch(data: MatchDTO) {
  return axios.post(`${import.meta.env.VITE_API_Admin_URL}match/create/pointRace`, data);
}
